home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Tele / T / TL0.2wCd.cpt / TabbyLogger Code / Source / Main.c next >
Encoding:
C/C++ Source or Header  |  1992-06-04  |  4.0 KB  |  109 lines  |  [TEXT/KAHL]

  1.     /* TabbyLogger.c */
  2. /* This is based on  a program that does nothing  It is provided as an example or shell for making programs in  */
  3. /* Think C that work with Tabby. Use it as you wish.  Give credit for this to Kirk Crawford if */
  4. /* you wish. As of 6/3/92 this worked with Think C version 5.0.2.  This is actually a cut */
  5. /* down version of TSort version 1.2.  No warranties are expressed or implied.  If this thing */
  6. /* screws up your computer, don't come to me.  It's free, you get what you pay for, etc.... */
  7. /* Kirk Crawford, FidoNet Node 1:102/132  Insert a call to your subroutine in the lower portion */
  8. /* of main()  Make sure you have the Set Project Type... stuff set the same.*/
  9. #include <String.h>
  10. #include <stdlib.h>
  11. int sprintf(unsigned char *dest, char *fmt, ...);
  12. int sscanf(unsigned char *dest, char *fmt, ...);
  13. #include "Main.p"
  14. #include <tabbyutils.h>
  15. #include <TabbyUtils.proto.h>
  16. #include "TabbyLogger.proto.h"
  17.  
  18. /* #define _DEBUG_ */        /* for use when Debugging Generic Import file */
  19. #define VerDlgID 128        /* Resource ID of the Dialog Box */
  20.  
  21. SysEnvRec    gMac;            /* info about the machine we are using */
  22. int            MyvRefNum,        /* four globals for the Tabby Utils file */
  23.             MultiFinder;    /* true when multifinder is running */
  24. Str255        BBSName,    /* name of the BBS program or last ditch launch program */
  25.             ProgName;    /* name of this program */
  26. main()
  27. {
  28.     DialogPtr        VerDlg;    /* something to show on the screen */
  29.     VersRecHndl        version;/* to find our version */
  30.     Str255            VerStr,    /* the version of this program */
  31.                     s;    /* useful string */
  32.     unsigned long    sleep=10;    /* how long to sleep when multifindering */
  33.     int                i;            /* usefull int */
  34.     EventRecord        event;        /* those useful events */
  35.     
  36.     /* initialize */
  37.     strcpy(ProgName,(unsigned char *)"TabbyLogger");    /* set our program name */
  38.     MaxApplZone();                    /* get memory */
  39.     MoreMasters();                    /* get master pointers */
  40.     InitGraf(&thePort);                /* start QuickDraw */
  41.     InitFonts();                    /* Start the Fonts */
  42.     InitWindows();                    /* Start the Windows */
  43.     InitMenus();                    /* start the Menus */
  44.     TEInit();                        /* Start Text Edit */
  45.     InitDialogs(nil);                /* Start The Dialogs */
  46.     SysEnvirons(2,&gMac);            /* check out the macintosh */
  47.     InitCursor();                    /* Change to The Arrow Cursor */
  48.     EventAvail(everyEvent, &event);    /* so that we come up in the foreground in MF */
  49.     EventAvail(everyEvent, &event);
  50.     EventAvail(everyEvent, &event);
  51.     FlushEvents(everyEvent,0);        /* dump any leftover events */
  52.     /* get the version */
  53.     version = (VersRecHndl)GetResource('vers',1);
  54.     if(!version){
  55.         sprintf(VerStr,"UnKnown");
  56.     } else {
  57.         HLock(version);
  58.             PtoCstr((char *)(**version).shortVersion);
  59.             strcpy(VerStr,(unsigned char *)(**version).shortVersion);
  60.         HUnlock(version);
  61.         ReleaseResource(version);
  62.     }
  63.     /* get my local vRefNum */
  64.     if(GetVol(s,&MyvRefNum))
  65.         ExitToShell();
  66.     /* log our starting */
  67.     sprintf(s,"Program Starting, Version %s",VerStr);
  68.     Log(s);
  69.     /* show the dialog box */
  70.     if((VerDlg = GetNewDialog(VerDlgID,nil,(WindowPtr)-1))){
  71.         centerwindow(VerDlg,&screenBits.bounds);
  72.         ShowWindow(VerDlg);
  73.         DrawDialog(VerDlg);
  74.     }
  75.     MultiFinder = FALSE;                /* set the default values */
  76.     sprintf(BBSName,"Second Sight");
  77.     CtoPstr(BBSName);
  78.     GetTabbyConfigStuff();                    /* get the real values */
  79.     if(MultiFinder)                        /* let the last app die if it wants to */
  80.         for(i=0; i<20; i++)
  81.             WaitNextEvent(everyEvent, &event, sleep, nil);
  82.     
  83.     /***********************************/
  84.     /* Insert your wonderful code here */
  85.     /***********************************/
  86.     DoIt();
  87.     /*******************/
  88.     
  89.     Log((unsigned char *)"Program Ending");                /* log the Ending */
  90.     if(VerDlg)                            /* kill the display */
  91.         DisposDialog(VerDlg);
  92.     LaunchNext(MyvRefNum);                /* probably won't come back from this */
  93.     ExitToShell();                        /* exit to finder if we do */
  94. }    /* that's all folks */
  95.  
  96. /***********************************************************************************************/
  97. centerwindow(wind,r)
  98. WindowPtr    wind;
  99. Rect        *r;
  100. {
  101.     Rect    r2;
  102.  
  103.     r2 = wind->portRect;
  104.     MoveWindow    (wind,
  105.                 ((r->right-r->left)-(r2.right-r2.left))/2 - r->left,
  106.                 ((r->bottom-r->top)-(r2.bottom-r2.top))/2 - r->top,
  107.                 FALSE);
  108. }
  109.